import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:seedfour/app/views/module_notice/notice_detail/state.dart';
import 'package:seedfour/toolkit/typedef/function.dart';

import '../../../../constants.dart';

class BottomBarWidget extends StatelessWidget {
  final NoticeDetailState data;
  final ParamVoidCallback onClickProgress;
  final ParamVoidCallback onClickReturn;
  final ParamVoidCallback onClickReceive;
  final ParamVoidCallback onClickDeal;

  const BottomBarWidget({
    Key? key,
    required this.data,
    required this.onClickProgress,
    required this.onClickReturn,
    required this.onClickReceive,
    required this.onClickDeal,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      if (data.noticeData.value.status == 0) {
        return _buildOneButton();
      } else if (data.noticeData.value.status == 1 &&
          data.noticeData.value.receiveUid == data.ownerUid.value) {
        return _buildThreeButton();
      } else {
        return const SizedBox();
      }
    });
  }

  Widget _buildOneButton() {
    return BottomAppBar(
      height: 72.w,
      color: Colors.white,
      child: Obx(() {
        return FilledButton(
          style: ElevatedButton.styleFrom(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(kRadiusMedium),
            ),
          ),
          onPressed: data.noticeData.value.status == 0 &&
                  data.noticeData.value.quota! > 0
              ? () => onClickReceive()
              : null,
          child: const Text('领取案源'),
        );
      }),
    );
  }

  Widget _buildThreeButton() {
    return BottomAppBar(
      height: 72.w,
      color: Colors.white,
      child: FilledButton(
        style: ElevatedButton.styleFrom(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(kRadiusMedium),
          ),
        ),
        onPressed: () => onClickProgress(),
        child: const Text('进度记录'),
      ),
    );
  }
}
